﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using DGM.Objects.General;
using DGM.Objects.Iso.Attributes;

namespace DGM.Objects.UClassify
{
    public class UClassifyTextLanguage
    {
        public string Version { get; set; }
        public string Success { get; set; }
        public int StatusCode { get; set; }
        public string ErrorMessage { get; set; }
        public double TextCoverage { get; set; }

        public UClassifyTextLanguagetValues Cls1 { get; set; }

        public Language GetCurrentLanguage()
        {
            return Cls1.GetHighestLanguage();
        }
    }

    public class UClassifyTextLanguagetValues
    {
        public Language GetHighestLanguage()
        {
            double probabilityHolder = 0;
            Language languageResult = Language.Arabic;

            var allLanguagesAndValues = GetAllLanguagesAndValues();

            foreach (Language language in allLanguagesAndValues.Keys)
            {
                double probabilityValue = allLanguagesAndValues[language];
                if (probabilityValue > probabilityHolder)
                {
                    probabilityHolder = probabilityValue;
                    languageResult = language;
                }
            }
            return languageResult;
        }

        public Dictionary<Language, double> GetAllLanguagesAndValues()
        {
            Dictionary<Language, double> supportedLanguages = new Dictionary<Language, double>();
            supportedLanguages.Add(Language.Arabic, Arabic);
            supportedLanguages.Add(Language.Bulgarian, Bulgarian);
            supportedLanguages.Add(Language.Catalan, Catalan);
            supportedLanguages.Add(Language.Croatian, Croatian);
            supportedLanguages.Add(Language.Czech, Czech);
            supportedLanguages.Add(Language.Danish, Danish);
            supportedLanguages.Add(Language.Dutch, Dutch);
            supportedLanguages.Add(Language.English, English);
            supportedLanguages.Add(Language.Filipino, Filipino);
            supportedLanguages.Add(Language.Finnish, Finnish);
            supportedLanguages.Add(Language.French, French);
            supportedLanguages.Add(Language.German, German);
            supportedLanguages.Add(Language.Greek, Greek);
            supportedLanguages.Add(Language.Hebrew, Hebrew);
            supportedLanguages.Add(Language.Hungarian, Hungarian);
            supportedLanguages.Add(Language.Indonesian, Indonesian);
            supportedLanguages.Add(Language.Italian, Italian);
            supportedLanguages.Add(Language.Latvian, Latvian);
            supportedLanguages.Add(Language.Lithuanian, Lithuanian);
            supportedLanguages.Add(Language.Norwegian, Norwegian);
            supportedLanguages.Add(Language.Polish, Polish);
            supportedLanguages.Add(Language.Portuguese, Portuguese);
            supportedLanguages.Add(Language.Romanian, Romanian);
            supportedLanguages.Add(Language.Russian, Russian);
            supportedLanguages.Add(Language.Serbian, Serbian);
            supportedLanguages.Add(Language.Slovak, Slovak);
            supportedLanguages.Add(Language.Slovenian, Slovenian);
            supportedLanguages.Add(Language.Spanish, Spanish);
            supportedLanguages.Add(Language.Swedish, Swedish);
            supportedLanguages.Add(Language.Turkish, Turkish);
            supportedLanguages.Add(Language.Ukrainian, Ukrainian);
            supportedLanguages.Add(Language.Vietnamese, Vietnamese);

            return supportedLanguages;
        }

        public double Arabic { get; set; }
        public double Bulgarian { get; set; }
        public double Catalan { get; set; }
        public double Croatian { get; set; }
        public double Czech { get; set; }
        public double Danish { get; set; }
        public double Dutch { get; set; }
        public double English { get; set; }
        public double Filipino { get; set; }
        public double Finnish { get; set; }
        public double French { get; set; }
        public double German { get; set; }
        public double Greek { get; set; }
        public double Hebrew { get; set; }
        public double Hungarian { get; set; }
        public double Indonesian { get; set; }
        public double Italian { get; set; }
        public double Latvian { get; set; }
        public double Lithuanian { get; set; }
        public double Norwegian { get; set; }
        public double Polish { get; set; }
        public double Portuguese { get; set; }
        public double Romanian { get; set; }
        public double Russian { get; set; }
        public double Serbian { get; set; }
        public double Slovak { get; set; }
        public double Slovenian { get; set; }
        public double Spanish { get; set; }
        public double Swedish { get; set; }
        public double Turkish { get; set; }
        public double Ukrainian { get; set; }
        public double Vietnamese { get; set; }
    }

    
}
